Skip to content

Close tab on middle-click (#9699)#9767

Open
pavanmanishd wants to merge 3 commits intopgadmin-org:masterfrom
pavanmanishd:fix/9699-middle-click-tab
Open

Close tab on middle-click (#9699)#9767
pavanmanishd wants to merge 3 commits intopgadmin-org:masterfrom
pavanmanishd:fix/9699-middle-click-tab

Conversation

@pavanmanishd
Copy link
Copy Markdown

@pavanmanishd pavanmanishd commented Mar 21, 2026

Closes #9699

Enable middle-click tab close behavior by handling mouse button 1 on the tab title and closing the tab when it is closable. preventDefault() is used to avoid browser auto-scroll on middle click.

Summary by CodeRabbit

  • New Features
    • Added middle-click support to close closable tabs: users can now close a tab with the browser/mouse middle button for faster tab management without changing other tab behaviors.

Add onMouseDown handler to the tab close button that fires layoutDocker.close()
when mouse button 1 (middle click) is pressed. preventDefault() stops the
browser's auto-scroll cursor from appearing.

This matches the standard UX in Chrome, Firefox, and VS Code where middle-click
on a tab closes it.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 179f58c4-ca71-475e-b810-abc5614fcfb1

📥 Commits

Reviewing files that changed from the base of the PR and between d6d0b2c and 15b34b5.

📒 Files selected for processing (1)
  • web/pgadmin/static/js/helpers/Layout/index.jsx

Walkthrough

Adds a middle-click handler to tab titles: when a closable tab is middle-clicked (mouse button 1), the event is prevented and the tab is closed via layoutDocker.close(id).

Changes

Cohort / File(s) Summary
Tab Middle-Click Handler
web/pgadmin/static/js/helpers/Layout/index.jsx
Added an onMouseDown handler to TabTitle's Box that detects middle-button clicks (e.button === 1) on closable tabs, calls e.preventDefault(), and invokes layoutDocker.close(id). Existing onContextMenu behavior retained.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TabTitle
    participant LayoutDocker
    participant LayoutUI

    User->>TabTitle: middle-click (mouse button 1)
    TabTitle->>TabTitle: onMouseDown handler\ncheck closable && e.button === 1
    TabTitle-->>User: e.preventDefault()
    TabTitle->>LayoutDocker: close(id)
    LayoutDocker->>LayoutUI: remove tab / update layout
    LayoutUI-->>User: UI updated (tab closed)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding middle-click functionality to close tabs, which directly matches the primary objective.
Linked Issues check ✅ Passed The implementation adds an onMouseDown handler that detects middle-click (button 1) and calls layoutDocker.close(), directly fulfilling the requirement to close tabs on middle-click as specified in issue #9699.
Out of Scope Changes check ✅ Passed The changes are limited to adding an onMouseDown handler to the TabTitle component for middle-click detection and tab closure, which is directly in scope with the linked issue objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pavanmanishd pavanmanishd marked this pull request as ready for review March 22, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Middle clicking tab should close it

2 participants